package ee.subjects.backend.model.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import ee.subjects.backend.model.dao.factory.DAOFactory;
import ee.subjects.backend.model.data.Contact;
import ee.subjects.backend.model.util.HibernateUtil;

public class TESTHibernateDAOs 
{
	public static void main(String[] args) 
	{
		DAOFactory daoFactory = DAOFactory.getDAOFactory();
		SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
		Session session = sessionFactory.openSession();
		session.beginTransaction();
		ContactHibernateDAO contactHibernateDAOImpl = daoFactory.getContactHibernateDAOImpl(session);
		
		/*
		Contact contactReceived = contactHibernateDAOImpl.findContactById(1);
		System.out.println(contactReceived.getContact());
		System.out.println(contactReceived.getSubject_fk());
		System.out.println(contactReceived.getSubjectTypeWithHibernate().getSubject_type());
		System.out.println(contactReceived.getContactTypeWithHibernate().getContact_type());
		System.out.println(contactReceived.getValue_text());
		System.out.println(contactReceived.getOrderby());
		System.out.println(contactReceived.getNote());
		*/
		
		/*
		contactHibernateDAOImpl.deleteContactById(58);
		*/
		int PERSON_TYPE_IDENTIFICATOR = 1;
		List<Contact> listOfAllPersonConatcts = contactHibernateDAOImpl.getAllSubjectContacts(2, PERSON_TYPE_IDENTIFICATOR);
		for (Contact personContact : listOfAllPersonConatcts)
		{
			System.out.println(personContact.getContact());
			System.out.println(personContact.getSubject_fk());
			System.out.println(personContact.getSubjectTypeWithHibernate().getSubject_type());
			System.out.println(personContact.getContactTypeWithHibernate().getContact_type());
			System.out.println(personContact.getValue_text());
			System.out.println(personContact.getOrderby());
			System.out.println(personContact.getNote());
			System.out.println("PEAKS nullid olema: " + personContact.getContact_type_fk());
			System.out.println("PEAKS nullid olema: " + personContact.getSubject_type_fk());
			System.out.println();
		}
		
		session.getTransaction().commit();
		session.close();
	}
}
